Ninja Database Pro
Using IsDeleted
Basic Tasks > Using IsDeleted

When saving a list of items if the class implements IsDeleted as a property and it is true, the item will be deleted when it is saved.

 

//Create a couple vendors

List<Vendor> vendors = new List<Vendor>();

 

Vendor vendor1 = new Vendor();

vendor1.Name = "Acme Rocket Motors Inc.";

vendor1.IsDirty = true;

vendors.Add(vendor1);

 

Vendor vendor2 = new Vendor();

vendor2.Name = "Acme Windshield Wipers Inc.";

vendor2.IsDirty = true;

vendors.Add(vendor2);

 

_ninjaDbPro.Save(vendors);

 

//Ensure they were saved

Vendor vendor1Copy = _ninjaDbPro.Load<Vendor>(vendor1.VendorID);

Vendor vendor2Copy = _ninjaDbPro.Load<Vendor>(vendor2.VendorID);

 

//Delete one

vendor2.IsDeleted = true;

_ninjaDbPro.Save(vendors);